<?php
/**
 * Created by PhpStorm.
 * User: itboye
 * Date: 2016/10/25
 * Time: 18:09
 */
namespace Admin\Controller;
use Think\Controller;
use Admin\Api\PicSearchApi;
use Admin\Api\GoodsFeedbackApi;

class PicSearchController extends Controller{
    //展示页
    public function index(){
        $page = array('curpage' => I('get.p', 0), 'size' => 10);
        $op_status = I('op_status',0);
        if(!empty($username = I('username'))){
            $this->assign('username',$username);
            $result  =  apicall(PicSearchApi::QUERY,[['op_status'=>$op_status,'username'=>$username],$page]);
        }else{
            $result  =  apicall(PicSearchApi::QUERY,[['op_status'=>$op_status],$page]);
        };
        if($result['status']){
            $list = $result['info']['list'];
            $show = $result['info']['show'];
            $this->assign('list',$list);
            $this->assign('show',$show);
            $this->assign('op_status',$op_status);
            $this->display();
        }else{
            $this->error($result['info']);
        }
    }
    //详情展示
    public function detail(){
        $id = I('id');
        $uname = I('username');
        if(empty($id)){
            $this->error('参数错误！');
        }
        $map = ['id'=>$id];
        $result = apiCall(PicSearchApi::QUERYNOPAGING,array($map));
        $imgs = $result['info'][0]['img_url_list'];
        if($result){
            $this->assign('result',$result['info']);
            $this->assign('id',$id);
            $this->assign('username',$uname);
            $this->assign('imgs',explode(",",$imgs));
            $this->display();
        }else{
            $this->error($result['info']);
        }
    }
    //请求删除
    public function del(){
        $id    = I('id');
        if(empty($id)){
            $this->error('参数错误！');
        }
        $map = ['id'=>$id];
        $result = apiCall(PicSearchApi::DELETE,array($map));
        if($result['status']){
            $this->success(L('RESULT_SUCCESS'),U('PicSearch/index'));
        }else{
            $this->error('操作失败!');
        }
    }
    //请求批量删除
    public function bulkDelete(){
        $ids    = I('ids');
        if(empty($ids)){
            $this->error('参数错误!');
        }
        $map = ['id'=>['in',$ids]];
        $result = apiCall(GoodsFeedbackApi::DELETE,array($map));
        if($result['status']){
            $this -> success(L('RESULT_SUCCESS'));
        }else{
            LogRecord('[INFO]' . $result['info'], '[FILE] ' . __FILE__ . ' [LINE] ' . __LINE__);
            $this->error($result['info']);
        }

    }
    //未处理请求查询
    public function  incomplete(){

    }
    //设为未处理
    public function  setincomplete(){
        $id    = I('id');
        if(empty($id)){
            $this->error('参数错误！');
        }
        $result = apiCall(PicSearchApi::SAVE_BY_ID,array($id,['op_status'=>0]));
        if($result['status']){
            $this->success(L('RESULT_SUCCESS'),U('PicSearch/index'));
        }else{
            $this->error('操作失败!');
        }
    }
    //已处理请求查询
    public function  completed(){

    }
    //设为已处理
    public function  setcompleted(){
        $id    = I('id');
        if(empty($id)){
            $this->error('参数错误！');
        }
        $result = apiCall(PicSearchApi::SAVE_BY_ID,array($id,['op_status'=>1]));
        if($result['status']){
            $this->success(L('RESULT_SUCCESS'),U('PicSearch/index'));
        }else{
            $this->error('操作失败!');
        }
    }
    //图片查询
    public function imgqry(){

    }
}